﻿using System;

using UnityEngine;
using UnityEngine.EventSystems;

/// <summary>
/// Very basic script that will activate or deactivate an object (and all of its children) when clicked.
/// </summary>

[AddComponentMenu("UGUI/Interaction/Button Activate")]
public class UGUIButtonActivate : MonoBehaviour, IPointerClickHandler
{
    public GameObject target;
    public bool state = true;

    void OnClick () { if (target != null) UGUITools.SetActive(target, state); }

    public void OnPointerClick(PointerEventData eventData)
    {
        OnClick();
    }
}